package can;

import static org.junit.Assert.assertEquals;
import org.junit.Test;

/**
 * Tests the getEstimatedDegree method by varying the values of each parameter individually.
 * 
 * @author Andrea
 * 
 */
public class TestConnellBotEstimatedDegree {

  /**
   * Varies the degree passed into getEstimatedDegree to cover all equivalence classes.
   */
  @Test
  public void testDegree() {
    ConnellBot bot = new ConnellBot();

    // bot.getEstimatedDegree(degChange, distance, heading, velocity, firePower, myX, myY, width,
    // height)
    assertEquals("Degree1", 18, (int) bot.getEstimatedDegree(0, 110, 45, 5, 3, 200, 200, 600, 600));
    assertEquals("Degree2", 44,
        (int) bot.getEstimatedDegree(45, 110, 45, 5, 3, 200, 200, 600, 600));
    assertEquals("Degree3", 71,
        (int) bot.getEstimatedDegree(90, 110, 45, 5, 3, 200, 200, 600, 600));
    assertEquals("Degree4", 108,
        (int) bot.getEstimatedDegree(135, 110, 45, 5, 3, 200, 200, 600, 600));
    assertEquals("Degree5", 162,
        (int) bot.getEstimatedDegree(180, 110, 45, 5, 3, 200, 200, 600, 600));
    assertEquals("Degree6", 225,
        (int) bot.getEstimatedDegree(225, 110, 45, 5, 3, 200, 200, 600, 600));
    assertEquals("Degree7", 287,
        (int) bot.getEstimatedDegree(270, 110, 45, 5, 3, 200, 200, 600, 600));
    assertEquals("Degree8", 341,
        (int) bot.getEstimatedDegree(315, 110, 45, 5, 3, 200, 200, 600, 600));
  }

  /**
   * Varies the distance passed into getEstimatedDegree to cover all equivalence classes.
   */
  @Test
  public void testDistance() {
    ConnellBot bot = new ConnellBot();

    assertEquals("Distance1", 45,
        (int) bot.getEstimatedDegree(60, 0, 45, 5, 3, 200, 200, 600, 600));
    assertEquals("Distance2", 47,
        (int) bot.getEstimatedDegree(70, 550, 45, 5, 3, 200, 200, 600, 600));
  }

  /**
   * Varies the heading passed into getEstimatedDegree to cover all equivalence classes.
   */
  @Test
  public void testHeading() {
    ConnellBot bot = new ConnellBot();

    assertEquals("Heading1", 11, (int) bot.getEstimatedDegree(45, 1, 0, 30, 3, 200, 200, 600, 600));
    assertEquals("Heading2", 45,
        (int) bot.getEstimatedDegree(45, 1, 45, 30, 3, 200, 200, 600, 600));
    assertEquals("Heading3", 78,
        (int) bot.getEstimatedDegree(45, 1, 90, 30, 3, 200, 200, 600, 600));
    assertEquals("Heading4", 114,
        (int) bot.getEstimatedDegree(45, 1, 135, 30, 3, 200, 200, 600, 600));
    assertEquals("Heading5", 160,
        (int) bot.getEstimatedDegree(45, 1, 180, 30, 3, 200, 200, 600, 600));
    assertEquals("Heading6", 225,
        (int) bot.getEstimatedDegree(45, 1, 225, 30, 3, 200, 200, 600, 600));
    assertEquals("Heading7", 289,
        (int) bot.getEstimatedDegree(45, 1, 270, 30, 3, 200, 200, 600, 600));
    assertEquals("Heading8", 335,
        (int) bot.getEstimatedDegree(45, 1, 315, 30, 3, 200, 200, 600, 600));
  }

  /**
   * Varies the velocity passed into getEstimatedDegree to cover all equivalence classes.
   */
  @Test
  public void testVelocity() {
    ConnellBot bot = new ConnellBot();
    assertEquals("Velocity1", 129,
        (int) bot.getEstimatedDegree(135, 110, 45, 1, 3, 200, 200, 700, 700));
    assertEquals("Velocity2", 75,
        (int) bot.getEstimatedDegree(135, 110, 45, 10, 3, 200, 200, 700, 700));
    assertEquals("Velocity3", 48,
        (int) bot.getEstimatedDegree(135, 110, 45, 15, 3, 200, 200, 700, 700));
  }

  /**
   * Varies the fire power passed into getEstimatedDegree to cover all equivalence classes.
   */
  @Test
  public void testFirePower() {
    ConnellBot bot = new ConnellBot();
    assertEquals("Power1", 120,
        (int) bot.getEstimatedDegree(135, 110, 45, 5, .1, 200, 200, 600, 600));
    assertEquals("Power2", 118,
        (int) bot.getEstimatedDegree(135, 110, 45, 5, 1, 200, 200, 600, 600));
    assertEquals("Power3", 115,
        (int) bot.getEstimatedDegree(135, 110, 45, 5, 2, 200, 200, 600, 600));
    assertEquals("Power4", 109,
        (int) bot.getEstimatedDegree(135, 110, 45, 5, 2.9, 200, 200, 600, 600));
  }

  /**
   * Varies the origin passed into getEstimatedDegree to cover all equivalence classes.
   */
  @Test
  public void testOrigin() {
    ConnellBot bot = new ConnellBot();
    assertEquals("Origin1", 39, (int) bot.getEstimatedDegree(35, 110, 45, 5, 3, 0, 0, 600, 600));
    assertEquals("Origin2", 39, (int) bot.getEstimatedDegree(35, 110, 45, 5, 3, 300, 0, 600, 600));
    assertEquals("Origin3", 39, (int) bot.getEstimatedDegree(35, 110, 45, 5, 3, 0, 300, 600, 600));
    assertEquals("Origin4", 39,
        (int) bot.getEstimatedDegree(35, 110, 45, 5, 3, 300, 300, 600, 600));
    assertEquals("Origin5", 90, (int) bot.getEstimatedDegree(35, 110, 45, 5, 3, 0, 600, 600, 600));
    assertEquals("Origin6", 0, (int) bot.getEstimatedDegree(35, 110, 45, 5, 3, 600, 0, 600, 600));
    assertEquals("Origin7", 45,
        (int) bot.getEstimatedDegree(35, 110, 45, 5, 3, 600, 600, 600, 600));
  }

  /**
   * Varies the combination of degree and heading passed into getEstimatedDegree to generate 
   * various xdist and ydist values.
   */
  @Test
public void testDegreeAndHeading() {
    ConnellBot bot = new ConnellBot();

    assertEquals("D&H1", 270, (int) bot.getEstimatedDegree(90, 11, 270, 11, 3, 200, 200, 600, 600));
    assertEquals("D&H2", 90, (int) bot.getEstimatedDegree(90, 11, 90, 11, 3, 200, 200, 600, 600));
    assertEquals("D&H3", 270,
        (int) bot.getEstimatedDegree(270, 11, 270, 11, 3, 200, 200, 600, 600));
    assertEquals("D&H4", 180,
        (int) bot.getEstimatedDegree(180, 11, 180, 11, 3, 200, 200, 600, 600));
    assertEquals("D&H5", 0, (int) bot.getEstimatedDegree(0, 11, 0, 11, 3, 200, 200, 600, 600));
  }

}
